﻿function K_NS()
{
//自定义的HTML marker标注类型，以指定点显示HTML内容
	function K_HtmlMarker(icon,point,html)
	{
		this.icon=icon;
		this.point=point;
		this.html=html;
	}
	K_HtmlMarker.prototype = new GOverlay();
	K_HtmlMarker.prototype.initialize=function(a)
	{
		this.map=a;
		a.addOverlay(this.icon);
		this.icon.setPoint(this.point);
		GEvent.bindDom(this.icon,"mousedown",this,this.onMouseDown);
		this.div=document.createElement("span");
		this.div.align="left";
		this.div.style.position="absolute";
		this.div.style.cursor="default";
		this.div.style.width="200px";
		this.div.innerHTML=this.html;
		a.getPane(G_MAP_MARKER_PANE).appendChild(this.div);
		GEvent.bind(this.icon,"click",this,this.onMouseDown);
	};
	K_HtmlMarker.prototype.remove=function(){this.icon.remove();if(this.div&&this.div.parentNode){this.div.parentNode.removeChild(this.div)}};
	K_HtmlMarker.prototype.copy=function()
	{
		return new K_HtmlMarker(this.icon.copy(),this.point,this.html)
	};
	K_HtmlMarker.prototype.redraw=function(a)
	{
		this.icon.redraw(a);
		if(!a)return;
		var c=this.map.fromLatLngToDivPixel(this.point);
		iconSize=this.icon.getIcon().iconSize?this.icon.getIcon().iconSize:new GSize(32,32);
		this.div.style.left=(c.x+iconSize.width/2)+"px";
		this.div.style.top=(c.y-this.div.offsetHeight/2)+"px";
	};
	K_HtmlMarker.prototype.onMouseDown=function(a)
	{
		if(document.all)
		{
			window.event.cancelBubble=true;
			window.event.returnValue=false
		}
		else
		{
			a.cancelBubble=true;
			a.preventDefault();
			a.stopPropagation()
		}
		GEvent.trigger(this,"click",this);
	};
	K_HtmlMarker.prototype.openInfoWindowHtml=function(html)
	{
		this.map.openInfoWindowHtml(this.point,html);
	}
	window.K_HtmlMarker=K_HtmlMarker;
}K_NS();